package com.itheima.reggie.common;


import com.itheima.reggie.domain.User;

public class UserHolder {

    //维护一个ThreadLocal对象
    private static ThreadLocal<User> threadLocal = new ThreadLocal<>();

    //给ThreadLocal对象放入User
    public static void set(User user){
        threadLocal.set(user);
    }


    //获取ThreadLocal中的user
    public static User get(){
        return threadLocal.get();
    }


    //移除ThreadLocal中的User
    public static void remove(){
        threadLocal.remove();
    }

}
